using System;
using System.Collections;
using System.Collections.Specialized;
using System.Runtime.InteropServices;
namespace BMC.ARSystem
{
	[ClassInterface, Guid("da1ac86a-ea41-4698-9780-9a62467eaf6b"), ProgId("BMC.ARSystem.ActiveLinkGuide")]
	public class ActiveLinkGuide : Container
	{
		public ArrayList Items
		{
			get
			{
				ArrayList arrayList = new ArrayList();
				IEnumerator enumerator = this._references.GetEnumerator();
				try
				{
					while (enumerator.MoveNext())
					{
						Reference reference = (Reference)enumerator.get_Current();
						if (reference.ReferenceType == 5)
						{
							arrayList.Add(new ActiveLinkGuideItem(reference.Name));
						}
						else
						{
							arrayList.Add(new ActiveLinkGuideItem(reference.Label, true));
						}
					}
				}
				finally
				{
					IDisposable disposable = enumerator as IDisposable;
					if (disposable != null)
					{
						disposable.Dispose();
					}
				}
				return ArrayList.ReadOnly(arrayList);
			}
			set
			{
				base.MembersModified = new BitVector32(base.MembersModified.get_Data() | 256);
				this._references.Clear();
				IEnumerator enumerator = value.GetEnumerator();
				try
				{
					while (enumerator.MoveNext())
					{
						ActiveLinkGuideItem item = (ActiveLinkGuideItem)enumerator.get_Current();
						this.AddItem(-1, item);
					}
				}
				finally
				{
					IDisposable disposable = enumerator as IDisposable;
					if (disposable != null)
					{
						disposable.Dispose();
					}
				}
			}
		}
		public ActiveLinkGuide()
		{
		}
		internal ActiveLinkGuide(object[] rawData, Server server) : base(rawData, server)
		{
		}
		private void AddItem(Reference item)
		{
			base.MembersModified = new BitVector32(base.MembersModified.get_Data() | 256);
			base.AddItem(item);
		}
		private Reference PrepareReference(ActiveLinkGuideItem item)
		{
			Reference reference;
			if (item.IsLabel)
			{
				reference = new ExternalReference(32774);
				reference.Label = item.Value;
			}
			else
			{
				reference = new Reference(5, item.Value);
			}
			return reference;
		}
		public void AddItem(int index, ActiveLinkGuideItem item)
		{
			base.MembersModified = new BitVector32(base.MembersModified.get_Data() | 256);
			Reference reference = this.PrepareReference(item);
			if (item.IsLabel && this._references.Contains(reference))
			{
				throw new Exception("Label must be unique");
			}
			if (index < 0 || index > base.References.get_Count())
			{
				this.AddItem(reference);
				return;
			}
			this._references.Insert(index, reference);
		}
		public void RemoveAt(int index)
		{
			this._references.RemoveAt(index);
		}
	}
}
